define([
  'utils/Conf',
  'models/Model'
], function(Conf, Model){
  var Familiar = Model.extend({
    initialize: function(options) {
      options || (options = {});
      if(options.internal) {
        this.internal = options.internal;
      }
    },
    
    url: function() {
      var urlBase = Conf.routes.familiars.list;
      if(this.id) {
        urlBase += "/" + this.id;
      }
      return urlBase;
    },

    // Save and update methods depend on the internal user.
    save: function(attrs, options) {
      options || (options = {});
      if(this.internal) {
        options.url = Conf.routes.internals.list;
        options.url += "/" + this.internal + Conf.routes.internals.familiars;
      }
      Model.prototype.save.call(this, attrs, options);
    },
    
    destroy: function(options) {
      options || (options = {});
      options.url = Conf.routes.internals.list;
      if(this.internal) {
        options.url += this.internal.id + "/" + Conf.routes.internals.familiars;
      }

      Model.prototype.destroy.call(this, options);
    }
  });

  return Familiar;
});
